﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TM.DAL;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

namespace TM.Rules.Web.Rules
{
    public partial class DashBoard : System.Web.UI.Page
    {
        DalManager dalmanager = new DalManager();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
               

                BindData();


            }

        }

        private void BindData()
        {
            // make the query 
            string ConnectionString = ConfigurationManager.ConnectionStrings["SMConnectionString"].ToString();

            string query = "SELECT [RuleID], [RuleName], [RuleType], [RuleText], [RuleDescription], [ExecutionOrder], [IsActive], [CreatedDate] FROM [Rules] ORDER BY [ExecutionOrder]";


            SqlConnection myConnection = new SqlConnection(ConnectionString);
            SqlDataAdapter ad = new SqlDataAdapter(query, myConnection);
            DataSet ds = new DataSet();
            ad.Fill(ds, "Rules");
            grdMyRules.DataSource = ds;
            grdMyRules.DataBind();

            grdPublicRules.DataSource = ds;
            grdPublicRules.DataBind();

            grdProtectedRules.DataSource = ds;
            grdProtectedRules.DataBind();

        }
    }
}